package com.sky.mapper;

import com.sky.entity.ShoppingCart;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * ClassName: ShoppingCartMapper
 * Package: com.sky.mapper
 * Description:
 *
 * @Autehor 屈子岩
 * @Create 2024/9/14 13:50
 * @Version 1.0
 */
@Mapper
public interface ShoppingCartMapper {

    @Select("select * from shopping_cart")
    List<ShoppingCart> list();

    /**
     * 根据用户Id等 查询购物车信息
     * @param shoppingCart
     * @return
     */
    List<ShoppingCart> query(ShoppingCart shoppingCart);


    /**
     * 修改购物车中商品数量
     * @param cart
     */
    @Update("update shopping_cart set number = #{number} where id = #{id}")
    void update(ShoppingCart cart);

    @Insert("insert into shopping_cart(name, image, user_id, dish_id, setmeal_id, dish_flavor, amount, create_time) " +
            "VALUES (#{name},#{image},#{userId},#{dishId},#{setmealId},#{dishFlavor},#{amount},#{createTime})")
    void insert(ShoppingCart shoppingCart);

    /**
     * 清空购物车
     */
    @Delete("delete from shopping_cart")
    void clean();

    @Select("select * from shopping_cart where user_id = #{userId}")
    List<ShoppingCart> getbyId(Long userId);

    /**
     * 批量插入购物车数据
     *
     * @param shoppingCartList
     */
    void insertBatch(List<ShoppingCart> shoppingCartList);

    /**
     * 根据菜品id或者套餐id查询购物车
     * @param dishId
     * @return
     */
  //  ShoppingCart getBydishIdOrsetmealId(Long id);


    /**
     * 更新购物车中商品的数量
     * @param shoppingCart
     */
//    @Update("update shopping_cart set number = #{number} where id = #{id}")
//    void updateNumber(ShoppingCart shoppingCart);


   // void save(ShoppingCart shoppingCart);
}
